package com.knowif.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.knowif.dao.SpecialMapper;
import com.knowif.pojo.Special;
import com.knowif.pojo.SpecialExample;

/**
 * @author ：Xh
 * @date ：Created in 2019/5/4 0004 21:28
 */
@Service
public class Special_service {

    @Autowired
    private SpecialMapper specialMapper;

    /**
     * Special条件查询
     * @param specialExample
     * @return
     */
    public List<Special> selectSpecial(SpecialExample specialExample){
        return specialMapper.selectByExample(specialExample);
    }

    /**
     * 插入special
     * @param special
     * @return
     */
    public int saveSpecial(Special special){
        return specialMapper.insert(special);
    }

    /**
     * 更新不为空的special属性
     * @param special
     * @return
     */
    public int updateSpecialNotNull(Special special){
        return specialMapper.updateByPrimaryKeySelective(special);
    }

    /**
     * 更新所有special属性
     * @param special
     * @return
     */
    public int updateSpecial(Special special){
        return specialMapper.updateByPrimaryKey(special);
    }

    /**
     * 删除special
     * @param specialId
     */
    public int deleteSpecial(int specialId){
        return specialMapper.deleteByPrimaryKey(specialId);
    }
    
    
    public List<Special> selectSpecialBySpecialds(List<Integer> specialIds){
    	if(specialIds == null || specialIds.isEmpty()){
    		return new ArrayList<Special>();
    	}
    	SpecialExample specialExample = new SpecialExample();
    	specialExample.createCriteria().andIdIn(specialIds);
    	List<Special> specials = specialMapper.selectByExample(specialExample);
    	if(specials == null || specials.isEmpty()){
    		return new ArrayList<Special>();
    	}else{
    		return specials;
    	}
    }
}
